package com.atguigu.lease.exception;

import com.atguigu.lease.result.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(Exception.class)
    public Result fail(Exception e){
        e.printStackTrace();//异常信息打印 打印到控制太 | 工作打印到日志中
        return Result.fail();
    }

    @ExceptionHandler(LeaseException.class)
    public Result fail(LeaseException e){
        e.printStackTrace();//异常信息打印 打印到控制台 | 工作打印到日志中
        return Result.build(e.getResultCodeEnum());
    }
}
